package com.maple.sdk.controller;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;

import com.maple.sdk.util.CustomDateEditor;
/**
 * @Description BaseController
 * @author 李铭浩
 * @Date 2012-11-4
 * @Porject  BasicRole
 */
@Controller
@RequestMapping("/baseController")
public class BaseController {
	/**
	 * @Description 将前台传递过来的日期格式的字符串，自动转化为Date类型
	 * @Author 李铭浩
	 * @Date 2012-11-4
	 * @return void
	 * @param binder
	 */
	@InitBinder
	public void initBinder(ServletRequestDataBinder binder) {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		// dateFormat.setLenient(false);
		binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
		// binder.registerCustomEditor(String.class, new StringTrimmerEditor(false));
	}
}
